import { defineConfig } from 'vite' // 使用 defineConfig 工具函数实现配置智能提示
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import { env } from 'process'

// https://vitejs.dev/config/
export default defineConfig({
  base: env.VITE_MODE === 'production' ? './' : '/',
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src/views')
    }
  },
  server: {
    host: '0.0.0.0',
    port: 8080,
    proxy: {
      '^/api': {
        target: 'https://xinxi00.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '^/api2': {
        target: 'https://www.58bc8.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api2/, '')
      }
    }
  },
})
